package cn.xiangxiang.controller.goods;

import cn.xiangxiang.pojo.common.Result;
import cn.xiangxiang.pojo.goods.Goods;
import cn.xiangxiang.pojo.goods.Spu;
import cn.xiangxiang.service.goods.SpuService;
import com.alibaba.dubbo.config.annotation.Reference;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/spu")
public class SpuController {

    @Reference
    private SpuService spuService;

    @RequestMapping("/findall")
    private List<Spu> findall(){
        return spuService.list();
    }

    @PostMapping("/findconditionpage")
    public Page<Spu> findConditionPage(Integer startpage, Integer pagesize, @RequestBody Spu spu){
        return spuService.findConditionPage(startpage,pagesize,spu);
    }

    @GetMapping("/findsgoodsbyid")
    public Goods findsgoodsbyid(String spuid){
        return spuService.findsgoodsbyid(spuid);
    }

    @PostMapping("/updateSpuSkuList")
    public Result updateSpuSkuList(@RequestBody Goods goods){
        spuService.updateSpuSkuList(goods);
        return  new Result();
    }

    @GetMapping("/delbyid")
    public Result delbyid(String id){
        spuService.delByIdAndSkuList(id);
        return new Result();
    }
}
